//package com.spring.data.jpa.demo.core.dao.impl;
//
//import java.util.List;
//
//import org.hibernate.Session;
//import org.hibernate.SessionFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Repository;
//
//import com.spring.data.jpa.demo.core.dao.TeamDao;
//import com.spring.data.jpa.demo.core.entity.Team;
//
//@Repository
//public class TeamDaoImpl implements TeamDao {
//
//	@Autowired
//	private SessionFactory sessionFactory;
//
//	private Session getCurrentSession() {
//		return sessionFactory.getCurrentSession();
//	}
//
//	@Override
//	public void addTeam(Team team) {
//		getCurrentSession().save(team);
//	}
//
//	@Override
//	public void updateTeam(Team team) {
//		Team teamToUpdate = getTeam(team.getId());
//		teamToUpdate.setName(team.getName());
//		teamToUpdate.setRating(team.getRating());
//
//		getCurrentSession().update(teamToUpdate);
//	}
//
//	@Override
//	public Team getTeam(Integer id) {
//		return (Team) getCurrentSession().get(Team.class, id);
//	}
//
//	@Override
//	public void deleteTeam(Integer id) {
//		Team teamToDelete = getTeam(id);
//		if(teamToDelete != null) {
//			getCurrentSession().delete(teamToDelete);
//		}
//	}
//
//	@Override
//	@SuppressWarnings("unchecked")
//	public List<Team> getTeams() {
//		return getCurrentSession().createQuery("from Team").list();
//	}
//
//}
